package com.example.service;

import com.example.common.Result;
import com.example.entity.Logs;
import com.example.mapper.LogsMapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class LogsService {
    @Autowired
    LogsMapper logsMapper;
    public void removeById(Integer id) {
        logsMapper.removeById(id);
    }

    public void deleteBatch(List<Integer> ids) {
        for(Integer id : ids){
            logsMapper.removeById(id);
        }
    }

    public PageInfo<Logs> selectPage(Logs logs, Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        List<Logs> list = logsMapper.selectAll(logs);
        return PageInfo.of(list);
    }

    /**
     * 保存日志
     * @param logs
     */
    public void save(Logs logs) {
        logsMapper.add(logs);
    }
}
